package com.fujimana.android.manacode;

import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;

public class SettingsActivity extends PreferenceActivity  {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.pref);
		  
        Preference pLineno = findPreference(getText(R.string.settings_lineni_key));     
        pLineno.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			
			@Override
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				return true;
			}
		});
        
        Preference pFontsize = findPreference(getText(R.string.settings_fontsize_key));     
        pFontsize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			
			@Override
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				int size = Integer.parseInt((String) newValue);
				return ((size >= 8) && (size<= 16));
			}
		});
        
        Preference pTabsize = findPreference(getText(R.string.settings_tabsize_key));     
        pTabsize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			
			@Override
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				int size = Integer.parseInt((String) newValue);
				return ((size >= 1) && (size<= 8));
			}
		});
	}
	
}
